<%--
  Created by IntelliJ IDEA.
  User: Fan307
  Date: 2016/11/18
  Time: 10:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>添加Catagory分类下的文件夹</title>
</head>
<body>
获取Web应用的物理路径即绝对路径：<%=application.getRealPath("/")%><br/>
当前你求请的JSP文件的物理路径：<%=application.getRealPath(request.getRequestURI())%><br/>
获取res目录路径："<%=request.getContextPath()%>/res"<br/>
根目录所对应的绝对路径:<%=request.getRequestURI()%><br>
<br>
<%
    String path = application.getRealPath("/") + "res" +"\\";
%>
Catagory下的路径：<%out.println(path);%>
            <td colspan="2" align="center">新建文件夹</td>
            <td>catagory</td>
            <td><input type="text" id="ca_value"></td>
    <%--<button onclick="Create(<%=path%>)">tijiao</button>--%>
<label style="cursor: pointer" onclick="Create('<%=path%>')" >点击添加</label>
<%--<input type="button" style="cursor: pointer" value="点击添加" onclick="Create('<%=path%>')" />--%>
<script type="text/javascript">
    function Create(str) {
        alert(str);
        var folderName = document.getElementById("ca_value").value;
        var strFolder = str + folderName;
        alert(strFolder);
        var objFSO = new ActiveXObject("Scripting.FileSystemObject");
        // 检查文件夹是否存在
        if (!objFSO.FolderExists(strFolder)){
// 创建文件夹
            var strFolderName = objFSO.CreateFolder(strFolder);
            document.write("创建文件夹: " + strFolderName + "<br>");
        }
        // 检查文件夹是否存在
        if (objFSO.FolderExists(strFolder)){
            document.write("文件夹: " + strFolder + "存在<br>");
// 删除文件夹
            objFSO.DeleteFolder(strFolder, false);
            document.write("删除文件夹: " + strFolder + "成功<br>");
        }
        else
            document.write("文件夹不存在<br>");

    }
</script>

</body>
</html>
